import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import { loadEnv } from 'vite';

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
      const env = loadEnv(mode, process.cwd());

    return {
        plugins: [
            vue(),
            vueJsx(),
            vueDevTools(),
        ],
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url))
            },
        },
        base: env.VITE_APP_BASE_URL,
        server: {
            port: 7100,
            proxy: {
                '/apis': {  // 根据接口路径特点，选择合适的匹配前缀，这里以'/auth-center'为例，可按需调整
                    target: 'http://129.151.238.145:7100',
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/apis/, '')
                }
            }
        },
    };
});
